package com.zx._12_算法.actual;

import org.junit.Test;

/**
 * @version v1.0
 * @Project: 20190215-demo
 * @Title: Recursion
 * @Description: 动态规划
 * @author: zhangxue
 * @date: 2019年4月14日上午9:43:53
 * @company: 未知之地
 * @Copyright: Copyright (c) 2019
 */
public class 动态规划 {

    public static int f(int n) {
        if (n == 1) {
            return 1;
        }
        if (n == 2) {
            return 2;
        }
        int a = 1;
        int b = 2;
        int temp = 0;
        for (int i = 3; i <= n; i++) {
            temp = a + b;
            a = b;
            b = temp;
        }

        return temp;
    }

    @Test
    public void test1() {
        System.out.println(f(10));
    }


}
